package com.egrand.sweetapi.plugin.db;

import com.egrand.sweetapi.plugin.db.configure.EgdTenantDataSourceProperties;
import com.egrand.sweetapi.plugin.db.provider.EgdTenantDataSourceProvider;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({EgdTenantDataSourceProperties.class})
public class DbAdapterConfiguration {

    @Bean
    public EgdTenantDataSourceProvider egdDataSourceProvider(EgdTenantDataSourceProperties egdTenantDataSourceProperties) {
        return new EgdTenantDataSourceProvider(egdTenantDataSourceProperties.getUrl(),
                egdTenantDataSourceProperties.getUsername(), egdTenantDataSourceProperties.getPassword());
    }
}
